import { _decorator, Component, Label, Node } from 'cc';
import { IRoom } from '../Common';
import EventManager from '../Global/EventManager';
import { EventEnum } from '../Enum';
const { ccclass, property } = _decorator;

@ccclass('RoomManager')
export class RoomManager extends Component {
    id:number;
    init({ id, players }: IRoom) {
        const label = this.node.getComponent(Label);
        label.string = `房间id:${id} 人数:${players.length} 玩家:${players.map(p => p.nickname).join(",")}`;
        this.node.active = true;
        this.id = id;
    }
    handleClick() {
        EventManager.Instance.emit(EventEnum.RoomJoin, this.id);
    }

}
